<?php

/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', FALSE);
ini_set('display_startup_errors', FALSE);
date_default_timezone_set('Europe/London');

define('EOL', (PHP_SAPI == 'cli') ? PHP_EOL : '<br />');

/** Include PHPExcel */
require_once dirname(__FILE__) . '/library/PHPExcel/Classes/PHPExcel/IOFactory.php';

$ean_file_name = 'EAN_code.xlsx';
$data = $_POST;
$error = array();
if (empty($data['BaseSKUName'])) {
    $error[] = 'Base SKU Name is invalid';
}
if (empty($data['Sizes'])) {
    $error[] = 'Sizes is invalid';
}

$caseEntries = array('T' => 'TOP', 'B' => 'BOTTOM', 'SET' => 'SET');

$postSizes = array();
foreach ($data['Sizes'] as $valueSizes) {
    $explodeValue = explode('{|}', $valueSizes);
    $postSizes[$explodeValue[0]] = $explodeValue[1];
}
$postColors = array();
if (isset($data['Colors']) && is_array($data['Colors'])) {
    foreach ($data['Colors'] as $keyColors => $valueColors) {
        $explodeValue = explode('{|}', $valueColors);
        $postColors[$explodeValue[0]] = $explodeValue[1];
    }
}

$actionForm = $data['actionForm'];
switch ($actionForm) {
    case 'generate-amazon-usa':
        $objPHPExcel = PHPExcel_IOFactory::load('amazon-template.xlsx');
        break;
    case 'generate-amazon-uk':
        $objPHPExcel = PHPExcel_IOFactory::load('amazon-uk-template.xlsx');
        break;
    case 'generate-amazon-de':
        $objPHPExcel = PHPExcel_IOFactory::load('amazon-de-template.xlsx');
        break;
    case 'generate-amazon-fr':
        $objPHPExcel = PHPExcel_IOFactory::load('amazon-fr-template.xlsx');
        break;
    case 'download-ean-file':
        if (file_exists($ean_file_name)) {
            $objPHPExcel = PHPExcel_IOFactory::load($ean_file_name);
        } else {
            $objPHPExcel = new PHPExcel();
        }
        break;

    default:
        $objPHPExcel = new PHPExcel();
        break;
}

$objPHPExcel->setActiveSheetIndex(0);


switch ($actionForm) {
    //Generate SKUs
    case 'generate-skus':
        $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'SKU');
        $objPHPExcel->getActiveSheet()->SetCellValue('B1', 'Name');
        $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Category');
        $objPHPExcel->getActiveSheet()->SetCellValue('D1', 'VariationGroup');
        $objPHPExcel->getActiveSheet()->SetCellValue('E1', 'Price');
        $objPHPExcel->getActiveSheet()->SetCellValue('F1', 'COLOR');
        $objPHPExcel->getActiveSheet()->SetCellValue('G1', 'BottomSize');
        $objPHPExcel->getActiveSheet()->SetCellValue('H1', 'TopSize');
        $objPHPExcel->getActiveSheet()->SetCellValue('I1', 'Size');
        $objPHPExcel->getActiveSheet()->SetCellValue('J1', 'Style');
        $objPHPExcel->getActiveSheet()->SetCellValue('K1', 'Description');
        $objPHPExcel->getActiveSheet()->SetCellValue('L1', 'PropertyType');
        $objPHPExcel->getActiveSheet()->SetCellValue('M1', 'PropertyName');
        $objPHPExcel->getActiveSheet()->SetCellValue('N1', 'PropertyValue');

        $row = 1;

        switch ($data['IsSetType']) {
            case 'IsBikiniSet':
                $file_name = $data['BaseSKUName'] . '-SKU.xlsx';
                if (count($postColors) > 0) {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        foreach ($postColors as $keyColors => $valueColors) {
                            foreach ($postSizes as $keySizes => $valueSizes) {
                                if ($valueEntries == 'SET') {
                                    foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                                        $row++;
                                        if ($data['StyleBeforeColor']) {
                                            $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-' . $keyColors . '-B' . $keySizes . '-T' . $keySizesSub;
                                        } else {
                                            $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-B' . $keySizes . '-T' . $keySizesSub;
                                        }
                                        $columnN = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '-' . $keyColors . '.jpg';

                                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnA);

                                        $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $data['LINNCategory']);

                                        $columnD = $data['BaseSKUName'] . '-' . $valueEntries;
                                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                        $columnE = $data[$valueEntries . 'PRICE'];
                                        $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);

                                        $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $valueColors);

                                        $columnI = $columnG = $columnH = '';
                                        if ($valueEntries == 'SET') {
                                            $columnG = $valueSizes;
                                            $columnH = $valueSizesSub;
                                        } else {
                                            $columnI = $valueSizesSub;
                                        }
                                        $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);

                                        $columnJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                                        $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);

                                        $columnK = $data['Description' . $valueEntries];
                                        $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                                        $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'Other');

                                        $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'IMAGE1');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, $columnN);
                                    }
                                } else {
                                    $row++;
                                    if ($data['StyleBeforeColor']) {
                                        $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-' . $keyColors . '-SZ' . $keySizes;
                                    } else {
                                        $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-SZ' . $keySizes;
                                    }
                                    $columnN = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '-' . $keyColors . '.jpg';

                                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnA);

                                    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $data['LINNCategory']);

                                    $columnD = $data['BaseSKUName'] . '-' . $valueEntries;
                                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                    $columnE = $data[$valueEntries . 'PRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);

                                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $valueColors);

                                    $columnI = $columnG = $columnH = '';
                                    if ($valueEntries == 'SET') {
                                        $columnG = $valueSizes;
                                        $columnH = $valueSizes;
                                    } else {
                                        $columnI = $valueSizes;
                                    }
                                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);
                                    $columnJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                                    $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);
                                    $columnK = $data['Description' . $valueEntries];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'Other');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'IMAGE1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, $columnN);
                                }
                            }
                        }
                    }
                } else {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            if ($valueEntries == 'SET') {
                                foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                                    $row++;
                                    $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-B' . $keySizes . '-T' . $keySizesSub;
                                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnA);

                                    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $data['LINNCategory']);

                                    $columnD = $data['BaseSKUName'] . '-' . $valueEntries;
                                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                    $columnE = $data[$valueEntries . 'PRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);

                                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, '');

                                    $columnI = $columnG = $columnH = '';
                                    if ($valueEntries == 'SET') {
                                        $columnG = $valueSizes;
                                        $columnH = $valueSizesSub;
                                    } else {
                                        $columnI = $valueSizesSub;
                                    }
                                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);

                                    $columnJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                                    $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);

                                    $columnK = $data['Description' . $valueEntries];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                                    $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'Other');

                                    $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'IMAGE1');

                                    $columnN = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '.jpg';
                                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, $columnN);
                                }
                            } else {
                                $row++;
                                $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-SZ' . $keySizes;
                                $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $data['LINNCategory']);

                                $columnD = $data['BaseSKUName'] . '-' . $valueEntries;
                                $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                $columnE = $data[$valueEntries . 'PRICE'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);

                                $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, '');

                                $columnI = $columnG = $columnH = '';
                                if ($valueEntries == 'SET') {
                                    $columnG = $valueSizes;
                                    $columnH = $valueSizes;
                                } else {
                                    $columnI = $valueSizes;
                                }
                                $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                                $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);

                                $columnJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                                $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);

                                $columnK = $data['Description' . $valueEntries];
                                $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                                $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'Other');

                                $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'IMAGE1');

                                $columnN = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '.jpg';
                                $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, $columnN);
                            }
                        }
                    }
                }
                break;
            case 'IsMixSet':
                $file_name = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-SKU.xlsx';
                if (count($postColors) > 0) {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        foreach ($postColors as $keyColors => $valueColors) {
                            foreach ($postSizes as $keySizes => $valueSizes) {
                                if ($valueEntries == 'SET') {
                                    foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                                        $row++;
                                        if ($data['StyleBeforeColor']) {
                                            $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $keyEntries . '-' . $keyColors . '-B' . $keySizes . '-T' . $keySizesSub;
                                        } else {
                                            $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $keyColors . '-' . $keyEntries . '-B' . $keySizes . '-T' . $keySizesSub;
                                        }
                                        $columnN = $data['ImageBase'] . '/' . $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $keyEntries . '-' . $keyColors . '.jpg';

                                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnA);

                                        $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $data['LINNCategory']);

                                        $columnD = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $valueEntries;
                                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                        $columnE = $data[$valueEntries . 'PRICE'];
                                        $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);

                                        $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $valueColors);

                                        $columnI = $columnG = $columnH = '';
                                        if ($valueEntries == 'SET') {
                                            $columnG = $valueSizes;
                                            $columnH = $valueSizesSub;
                                        } else {
                                            $columnI = $valueSizesSub;
                                        }
                                        $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);

                                        $columnJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                                        $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);

                                        $columnK = $data['Description' . $valueEntries];
                                        $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                                        $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'Other');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'IMAGE1');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, $columnN);
                                    }
                                }
                            }
                        }
                    }
                } else {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            if ($valueEntries == 'SET') {
                                foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                                    $row++;
                                    $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $keyEntries . '-B' . $keySizes . '-T' . $keySizesSub;
                                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnA);

                                    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $data['LINNCategory']);

                                    $columnD = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $valueEntries;
                                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                    $columnE = $data[$valueEntries . 'PRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);

                                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, '');

                                    $columnI = $columnG = $columnH = '';
                                    if ($valueEntries == 'SET') {
                                        $columnG = $valueSizes;
                                        $columnH = $valueSizesSub;
                                    } else {
                                        $columnI = $valueSizesSub;
                                    }
                                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);

                                    $columnJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                                    $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);

                                    $columnK = $data['Description' . $valueEntries];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                                    $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'Other');

                                    $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'IMAGE1');

                                    $columnN = $data['ImageBase'] . '/' . $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $keyEntries . '.jpg';
                                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, $columnN);
                                }
                            } else {
                                $row++;
                                $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $keyEntries . '-SZ' . $keySizes;

                                $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnA);

                                $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $data['LINNCategory']);

                                $columnD = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $valueEntries;
                                $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                $columnE = $data[$valueEntries . 'PRICE'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);

                                $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, '');

                                $columnI = $columnG = $columnH = '';
                                if ($valueEntries == 'SET') {
                                    $columnG = $valueSizes;
                                    $columnH = $valueSizes;
                                } else {
                                    $columnI = $valueSizes;
                                }
                                $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                                $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);

                                $columnJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                                $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);

                                $columnK = $data['Description' . $valueEntries];
                                $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                                $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'Other');

                                $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'IMAGE1');

                                $columnN = $data['ImageBase'] . '/' . $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $keyEntries . '.jpg';
                                $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, $columnN);
                            }
                        }
                    }
                }
                break;
            case 'IsOnePiece':
                $file_name = $data['BaseSKUName'] . '-SKU.xlsx';
                if (count($postColors) > 0) {
                    foreach ($postColors as $keyColors => $valueColors) {
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-SZ' . $keySizes;

                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnA);

                            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $data['LINNCategory']);

                            $columnD = $data['BaseSKUName'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                            $columnE = $data['OnePiecePrice'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $valueColors);
                            $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $valueSizes);

                            $columnJ = 'One Piece';
                            $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);

                            $columnK = $data['DescriptionOnePiece'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                            $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'Other');

                            $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'IMAGE1');

                            $columnN = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '.jpg';
                            $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, $columnN);
                        }
                    }
                } else {
                    foreach ($postSizes as $keySizes => $valueSizes) {
                        $row++;
                        $columnA = $data['BaseSKUName'] . '-SZ' . $keySizes;
                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                        $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnA);

                        $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $data['LINNCategory']);

                        $columnD = $data['BaseSKUName'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                        $columnE = $data['OnePiecePrice'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);
                        $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $valueSizes);

                        $columnJ = 'One Piece';
                        $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);

                        $columnK = $data['DescriptionOnePiece'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                        $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'Other');

                        $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'IMAGE1');

                        $columnN = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '.jpg';
                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, $columnN);
                    }
                }
                break;
        }

        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename="' . $file_name . '"');
        header('Cache-Control: max-age=0');
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        $objWriter->save('php://output');

        break;

    //Generate composites
    case 'generate-composites':
        $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'ParentSKU');
        $objPHPExcel->getActiveSheet()->SetCellValue('B1', 'ChildSKU');
        $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Quantity');
        $row = 1;
        switch ($data['IsSetType']) {
            case 'IsBikiniSet':
                $file_name = $data['BaseSKUName'] . '-COMPOSITES.xlsx';
                if (count($postColors) > 0) {
                    foreach ($postColors as $keyColors => $valueColors) {
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                                $row++;
                                if ($data['StyleBeforeColor']) {
                                    $columnA = $data['BaseSKUName'] . '-SET' . '-' . $keyColors . '-B' . $keySizes . '-T' . $keySizesSub;
                                    $columnB = $data['BaseSKUName'] . '-B-' . $keyColors . '-SZ' . $keySizes;
                                } else {
                                    $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-SET' . '-B' . $keySizes . '-T' . $keySizesSub;
                                    $columnB = $data['BaseSKUName'] . '-' . $keyColors . '-B-SZ' . $keySizes;
                                }

                                $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                                $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, '1');
                                $row++;
                                if ($data['StyleBeforeColor']) {
                                    $columnB = $data['BaseSKUName'] . '-T-' . $keyColors . '-SZ' . $keySizesSub;
                                } else {
                                    $columnB = $data['BaseSKUName'] . '-' . $keyColors . '-T-SZ' . $keySizesSub;
                                }

                                $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                                $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, '1');
                            }
                        }
                    }
                } else {
                    foreach ($postSizes as $keySizes => $valueSizes) {
                        foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-SET' . '-B' . $keySizes . '-T' . $keySizesSub;
                            $columnB = $data['BaseSKUName'] . '-B-SZ' . $keySizes;

                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, '1');
                            $row++;
                            if ($data['StyleBeforeColor']) {
                                $columnB = $data['BaseSKUName'] . '-SZ' . $keySizesSub . '-T';
                            } else {
                                $columnB = $data['BaseSKUName'] . '-T-SZ' . $keySizesSub;
                            }

                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, '1');
                        }
                    }
                }
                break;
            case 'IsMixSet':
                $file_name = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-COMPOSITES.xlsx';
                if (count($postColors) > 0) {
                    foreach ($postColors as $keyColors => $valueColors) {
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                                $row++;
                                if ($data['StyleBeforeColor']) {
                                    $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-SET-' . $keyColors . '-B' . $keySizes . '-T' . $keySizesSub;
                                    $columnB = $data['MixSetTOPSKU'] . '-B-' . $keyColors . '-SZ' . $keySizes;
                                } else {
                                    $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $keyColors . '-SET' . '-B' . $keySizes . '-T' . $keySizesSub;
                                    $columnB = $data['MixSetTOPSKU'] . '-' . $keyColors . '-B-SZ' . $keySizes;
                                }

                                $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                                $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, '1');
                                $row++;
                                if ($data['StyleBeforeColor']) {
                                    $columnB = $data['MixSetBOTTOMSKU'] . '-T-' . $keyColors . '-SZ' . $keySizesSub;
                                } else {
                                    $columnB = $data['MixSetBOTTOMSKU'] . '-' . $keyColors . '-T-SZ' . $keySizesSub;
                                }

                                $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                                $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, '1');
                            }
                        }
                    }
                } else {
                    foreach ($postSizes as $keySizes => $valueSizes) {
                        foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                            $row++;
                            $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-SET' . '-B' . $keySizes . '-T' . $keySizesSub;
                            $columnB = $data['MixSetTOPSKU'] . '-B-SZ' . $keySizes;

                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, '1');
                            $row++;
                            $columnB = $data['MixSetBOTTOMSKU'] . '-T-SZ' . $keySizesSub;

                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, '1');
                        }
                    }
                }
                break;
        }
        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename="' . $file_name . '"');
        header('Cache-Control: max-age=0');
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        $objWriter->save('php://output');
        break;

    //Generate magento
    case 'generate-magento':

        if ($data['IsSetType'] == 'IsMixSet') {
            $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'sku');
            $objPHPExcel->getActiveSheet()->SetCellValue('B1', 'has_options');
            $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'name');
            $objPHPExcel->getActiveSheet()->SetCellValue('D1', 'price');
            $objPHPExcel->getActiveSheet()->SetCellValue('E1', 'special_price');
            $objPHPExcel->getActiveSheet()->SetCellValue('F1', 'config_attributes');
            $objPHPExcel->getActiveSheet()->SetCellValue('G1', 'color');
            $objPHPExcel->getActiveSheet()->SetCellValue('H1', 'status');
            $objPHPExcel->getActiveSheet()->SetCellValue('I1', 'enable_googlecheckout');
            $objPHPExcel->getActiveSheet()->SetCellValue('J1', 'bottomsize');
            $objPHPExcel->getActiveSheet()->SetCellValue('K1', 'topsize');
            $objPHPExcel->getActiveSheet()->SetCellValue('L1', 'size');
            $objPHPExcel->getActiveSheet()->SetCellValue('M1', 'description');
            $objPHPExcel->getActiveSheet()->SetCellValue('N1', 'qty');
            $objPHPExcel->getActiveSheet()->SetCellValue('O1', 'is_in_stock');
            $objPHPExcel->getActiveSheet()->SetCellValue('P1', 'manage_stock');
            $objPHPExcel->getActiveSheet()->SetCellValue('Q1', 'use_config_manage_stock');
            $objPHPExcel->getActiveSheet()->SetCellValue('R1', 'product_name');
            $objPHPExcel->getActiveSheet()->SetCellValue('S1', 'product_type_id');
            $objPHPExcel->getActiveSheet()->SetCellValue('T1', 'gallery');
            $objPHPExcel->getActiveSheet()->SetCellValue('U1', 'related');
            $objPHPExcel->getActiveSheet()->SetCellValue('V1', 'upsell');
            $objPHPExcel->getActiveSheet()->SetCellValue('W1', 'crosssell');
            $objPHPExcel->getActiveSheet()->SetCellValue('X1', 'associated');
            $objPHPExcel->getActiveSheet()->SetCellValue('Y1', 'product_tags');
            $objPHPExcel->getActiveSheet()->SetCellValue('Z1', 'image');
            $objPHPExcel->getActiveSheet()->SetCellValue('AA1', 'small_image');
            $objPHPExcel->getActiveSheet()->SetCellValue('AB1', 'thumbnail');
            $objPHPExcel->getActiveSheet()->SetCellValue('AC1', 'visibility');
            $objPHPExcel->getActiveSheet()->SetCellValue('AD1', 'tax_class_id');
            $objPHPExcel->getActiveSheet()->SetCellValue('AE1', 'style');
        } else {
            $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'store');
            $objPHPExcel->getActiveSheet()->SetCellValue('B1', 'websites');
            $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'attribute_set');
            $objPHPExcel->getActiveSheet()->SetCellValue('D1', 'type');
            $objPHPExcel->getActiveSheet()->SetCellValue('E1', 'category_ids');
            $objPHPExcel->getActiveSheet()->SetCellValue('F1', 'sku');
            $objPHPExcel->getActiveSheet()->SetCellValue('G1', 'has_options');
            $objPHPExcel->getActiveSheet()->SetCellValue('H1', 'name');
            $objPHPExcel->getActiveSheet()->SetCellValue('I1', 'price');
            $objPHPExcel->getActiveSheet()->SetCellValue('J1', 'special_price');
            $objPHPExcel->getActiveSheet()->SetCellValue('K1', 'config_attributes');
            $objPHPExcel->getActiveSheet()->SetCellValue('L1', 'color');
            $objPHPExcel->getActiveSheet()->SetCellValue('M1', 'status');
            $objPHPExcel->getActiveSheet()->SetCellValue('N1', 'enable_googlecheckout');
            $objPHPExcel->getActiveSheet()->SetCellValue('O1', 'bottomsize');
            $objPHPExcel->getActiveSheet()->SetCellValue('P1', 'topsize');
            $objPHPExcel->getActiveSheet()->SetCellValue('Q1', 'size');
            $objPHPExcel->getActiveSheet()->SetCellValue('R1', 'description');
            $objPHPExcel->getActiveSheet()->SetCellValue('S1', 'qty');
            $objPHPExcel->getActiveSheet()->SetCellValue('T1', 'is_in_stock');
            $objPHPExcel->getActiveSheet()->SetCellValue('U1', 'manage_stock');
            $objPHPExcel->getActiveSheet()->SetCellValue('V1', 'use_config_manage_stock');
            $objPHPExcel->getActiveSheet()->SetCellValue('W1', 'product_name');
            $objPHPExcel->getActiveSheet()->SetCellValue('X1', 'product_type_id');
            $objPHPExcel->getActiveSheet()->SetCellValue('Y1', 'gallery');
            $objPHPExcel->getActiveSheet()->SetCellValue('Z1', 'related');
            $objPHPExcel->getActiveSheet()->SetCellValue('AA1', 'upsell');
            $objPHPExcel->getActiveSheet()->SetCellValue('AB1', 'crosssell');
            $objPHPExcel->getActiveSheet()->SetCellValue('AC1', 'associated');
            $objPHPExcel->getActiveSheet()->SetCellValue('AD1', 'product_tags');
            $objPHPExcel->getActiveSheet()->SetCellValue('AE1', 'image');
            $objPHPExcel->getActiveSheet()->SetCellValue('AF1', 'small_image');
            $objPHPExcel->getActiveSheet()->SetCellValue('AG1', 'thumbnail');
            $objPHPExcel->getActiveSheet()->SetCellValue('AH1', 'visibility');
            $objPHPExcel->getActiveSheet()->SetCellValue('AI1', 'tax_class_id');
            $objPHPExcel->getActiveSheet()->SetCellValue('AJ1', 'style');
        }

        $row = 1;

        switch ($data['IsSetType']) {
            case 'IsBikiniSet':
                $file_name = $data['BaseSKUName'] . '-MAGENTO.xlsx';

                if (count($postColors) > 0) {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        $associated = '';
                        foreach ($postColors as $keyColors => $valueColors) {
                            foreach ($postSizes as $keySizes => $valueSizes) {
                                if ($valueEntries == 'SET') {
                                    foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                                        $row++;
                                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, 'admin');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, 'base');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'MixedSizeSets');
                                        $columnD = 'simple';
                                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, '');
                                        if ($data['StyleBeforeColor']) {
                                            $columnF = $data['BaseSKUName'] . '-' . $keyEntries . '-' . $keyColors . '-B' . $keySizes . '-T' . $keySizesSub;
                                        } else {
                                            $columnF = $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-B' . $keySizes . '-T' . $keySizesSub;
                                        }

                                        $associated .= $columnF . ',';
                                        $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, '0');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnF);
                                        $columnI = $data[$valueEntries . 'PRICE'];
                                        $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, $valueColors);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'Enabled');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, 'Yes');
                                        $columnO = $valueSizes;
                                        $columnP = $valueSizesSub;
                                        $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, $columnP);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, '');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, '2');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '1');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '1');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('V' . $row, '1');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('W' . $row, $columnF);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $columnD);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, 'Not Visible Individually');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, 'Taxable Goods');
                                        $columnAJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                                        $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                                    }
                                } else {
                                    $row++;
                                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, 'admin');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, 'base');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'SizeStyleColour');
                                    $columnD = 'simple';
                                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, '');
                                    if ($data['StyleBeforeColor']) {
                                        $columnF = $data['BaseSKUName'] . '-' . $keyEntries . '-' . $keyColors . '-SZ' . $keySizes;
                                    } else {
                                        $columnF = $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-SZ' . $keySizes;
                                    }

                                    $associated .= $columnF . ',';
                                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, '0');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnF);
                                    $columnI = $data[$valueEntries . 'PRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, $valueColors);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'Enabled');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, 'Yes');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, $valueSizes);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, '');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, '2');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('V' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('W' . $row, $columnF);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $columnD);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, 'Not Visible Individually');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, 'Taxable Goods');
                                    $columnAJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                                }
                            }
                        }
                        $row++;

                        $columnC = 'SizeStyleColour';
                        if ($valueEntries == 'SET') {
                            $columnC = 'MixedSizeSets';
                        }

                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, 'admin');
                        $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, 'base');
                        $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $columnC);
                        $columnD = 'configurable';
                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                        $columnE = $data['Magento' . $valueEntries . 'Category'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);
                        $columnF = $data['BaseSKUName'] . '-' . $valueEntries;
                        $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                        $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, '1');
                        $columnH = $data['Magento' . $valueEntries . 'Name'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                        $columnI = $data[$valueEntries . 'PRICE'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);

                        $columnK = '';

                        if ($valueEntries != 'SET') {
                            if (count($postColors) > 0) {
                                $columnK = 'size,color';
                            } else {
                                $columnK = 'size';
                            }
                        } else {
                            if (count($postColors) > 0) {
                                $columnK = 'bottomsize,topsize,color';
                            } else {
                                $columnK = 'bottomsize,topsize';
                            }
                        }
                        $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                        $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'Enabled');
                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, 'Yes');
                        $columnR = $data['Description' . $valueEntries];
                        $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, $columnR);
                        $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('V' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('W' . $row, $columnH);
                        $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $columnD);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $associated);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, 'Catalog, Search');
                        $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, 'Taxable Goods');
                        $columnAJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                        $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                    }
                } else {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        $associated = '';
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            if ($valueEntries == 'SET') {
                                foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                                    $row++;
                                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, 'admin');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, 'base');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'MixedSizeSets');
                                    $columnD = 'simple';
                                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, '');
                                    $columnF = $data['BaseSKUName'] . '-' . $keyEntries . '-B' . $keySizes . '-T' . $keySizesSub;

                                    $associated .= $columnF . ',';
                                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, '0');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnF);
                                    $columnI = $data[$valueEntries . 'PRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, '');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'Enabled');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, 'Yes');
                                    $columnO = $valueSizes;
                                    $columnP = $valueSizesSub;
                                    $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, $columnP);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, '');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, '2');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('V' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('W' . $row, $columnF);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $columnD);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, 'Not Visible Individually');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, 'Taxable Goods');
                                    $columnAJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                                }
                            } else {
                                $row++;
                                $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, 'admin');
                                $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, 'base');
                                $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'SizeStyleColour');
                                $columnD = 'simple';
                                $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                                $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, '');
                                $columnF = $data['BaseSKUName'] . '-' . $keyEntries . '-SZ' . $keySizes;

                                $associated .= $columnF . ',';
                                $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                                $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, '0');
                                $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnF);
                                $columnI = $data[$valueEntries . 'PRICE'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);
                                $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, '');
                                $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'Enabled');
                                $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, 'Yes');
                                $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, $valueSizes);
                                $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, '');
                                $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, '2');
                                $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '1');
                                $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '1');
                                $objPHPExcel->getActiveSheet()->SetCellValue('V' . $row, '1');
                                $objPHPExcel->getActiveSheet()->SetCellValue('W' . $row, $columnF);
                                $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $columnD);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, 'Not Visible Individually');
                                $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, 'Taxable Goods');
                                $columnAJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                                $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                            }
                        }
                        $row++;
                        $columnC = 'SizeStyleColour';
                        if ($valueEntries == 'SET') {
                            $columnC = 'MixedSizeSets';
                        }
                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, 'admin');
                        $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, 'base');
                        $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $columnC);
                        $columnD = 'configurable';
                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                        $columnE = $data['Magento' . $valueEntries . 'Category'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);
                        $columnF = $data['BaseSKUName'] . '-' . $valueEntries;
                        $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                        $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, '1');
                        $columnH = $data['Magento' . $valueEntries . 'Name'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                        $columnI = $data[$valueEntries . 'PRICE'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);

                        $columnK = '';

                        if ($valueEntries != 'SET') {
                            if (count($postColors) > 0) {
                                $columnK = 'size,color';
                            } else {
                                $columnK = 'size';
                            }
                        } else {
                            if (count($postColors) > 0) {
                                $columnK = 'bottomsize,topsize,color';
                            } else {
                                $columnK = 'bottomsize,topsize';
                            }
                        }
                        $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                        $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'Enabled');
                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, 'Yes');
                        $columnR = $data['Description' . $valueEntries];
                        $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, $columnR);
                        $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('V' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('W' . $row, $columnH);
                        $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $columnD);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $associated);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, 'Catalog, Search');
                        $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, 'Taxable Goods');
                        $columnAJ = 'Bikini ' . ucfirst(strtolower($valueEntries));
                        $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                    }
                }
                break;
            case 'IsMixSet':
                $file_name = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-MAGENTO.xlsx';

                if (count($postColors) > 0) {
                    $associated = '';
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        foreach ($postColors as $keyColors => $valueColors) {
                            foreach ($postSizes as $keySizes => $valueSizes) {
                                if ($valueEntries == 'SET') {
                                    foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                                        $row++;
                                        if ($data['StyleBeforeColor']) {
                                            $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $keyEntries . '-' . $keyColors . '-B' . $keySizes . '-T' . $keySizesSub;
                                        } else {
                                            $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $keyColors . '-' . $keyEntries . '-B' . $keySizes . '-T' . $keySizesSub;
                                        }

                                        $associated .=$columnA . ',';
                                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $columnA);
                                        $columnD = $data[$valueEntries . 'PRICE'];
                                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $valueColors);
                                        $columnH = 'Enabled';
                                        $columnI = 'Yes';
                                        $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);
                                        $columnJ = $valueSizes;
                                        $columnK = $valueSizesSub;
                                        $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $valueSizes);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '2');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, '1');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '1');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '1');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, $columnA);
                                        $columnS = 'simple';
                                        $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, $columnS);
                                        $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, 'Not Visible Individually');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, 'Taxable Goods');
                                        $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, 'Bikini Set');
                                    }
                                }
                            }
                        }
                        if ($valueEntries == 'SET') {
                            $row++;
                            $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $valueEntries;
                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $data['MagentoSETName']);
                            $columnD = $data[$valueEntries . 'PRICE'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                            $columnF = '';
                            if (count($postColors)) {
                                $columnF = 'bottomsize,topsize,color';
                            } else {
                                $columnF = 'bottomsize,topsize';
                            }

                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);

                            $columnH = 'Enabled';
                            $columnI = 'Yes';
                            $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                            $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);
                            $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, '1');
                            $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '1');
                            $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '1');
                            $columnM = $data['DescriptionSET'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, $columnM);
                            $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, $data['MagentoSETName']);
                            $columnS = 'configurable';
                            $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, $columnS);
                            $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $associated);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, 'Catalog, Search');
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, 'Taxable Goods');
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, 'Bikini Set');
                        }
                    }
                } else {
                    $associated = '';
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            if ($valueEntries == 'SET') {
                                foreach ($postSizes as $keySizesSub => $valueSizesSub) {
                                    $row++;
                                    $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $keyEntries . '-B' . $keySizes . '-T' . $keySizesSub;

                                    $associated .=$columnA . ',';
                                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $columnA);
                                    $columnD = $data[$valueEntries . 'PRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, '');
                                    $columnH = 'Enabled';
                                    $columnI = 'Yes';
                                    $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);
                                    $columnJ = $valueSizes;
                                    $columnK = $valueSizesSub;
                                    $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $valueSizes);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '2');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, $columnA);
                                    $columnS = 'simple';
                                    $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, $columnS);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, 'Not Visible Individually');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, 'Taxable Goods');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, 'Bikini Set');
                                }
                            }
                        }
                        if ($valueEntries == 'SET') {
                            $row++;
                            $columnA = $data['MixSetTOPSKU'] . '-' . $data['MixSetBOTTOMSKU'] . '-' . $valueEntries;
                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, $data['MagentoSETName']);
                            $columnD = $data[$valueEntries . 'PRICE'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                            $columnF = '';
                            if (count($postColors)) {
                                $columnF = 'bottomsize,topsize,color';
                            } else {
                                $columnF = 'bottomsize,topsize';
                            }

                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);

                            $columnH = 'Enabled';
                            $columnI = 'Yes';
                            $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                            $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);
                            $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, '1');
                            $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '1');
                            $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '1');
                            $columnM = $data['DescriptionSET'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, $columnM);
                            $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, $data['MagentoSETName']);
                            $columnS = 'configurable';
                            $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, $columnS);
                            $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $associated);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, 'Catalog, Search');
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, 'Taxable Goods');
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, 'Bikini Set');
                        }
                    }
                }

                break;

            case 'IsOnePiece':
                $file_name = $data['BaseSKUName'] . '-MAGENTO.xlsx';

                if (count($postColors) > 0) {
                    $associated = '';
                    foreach ($postColors as $keyColors => $valueColors) {
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            $row++;
                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, 'admin');
                            $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, 'base');
                            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'SizeStyleColour');
                            $columnD = 'simple';
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, '');
                            $columnF = $data['BaseSKUName'] . '-' . $keyColors . '-SZ' . $keySizes;

                            $associated .= $columnF . ',';
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, '0');
                            $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnF);
                            $columnI = $data['OnePiecePrice'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);
                            $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, $valueColors);
                            $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'Enabled');
                            $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, 'Yes');
                            $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, $valueSizes);
                            $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, '');
                            $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, '2');
                            $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '1');
                            $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '1');
                            $objPHPExcel->getActiveSheet()->SetCellValue('V' . $row, '1');
                            $objPHPExcel->getActiveSheet()->SetCellValue('W' . $row, $columnF);
                            $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $columnD);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, 'Not Visible Individually');
                            $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, 'Taxable Goods');
                            $columnAJ = 'One Piece';
                            $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                        }
                    }
                    $row++;
                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, 'admin');
                    $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, 'base');
                    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'SizeStyleColour');
                    $columnD = 'configurable';
                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                    $columnE = $data['MagentoOnePieceCategory'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);
                    $columnF = $data['BaseSKUName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, '1');
                    $columnH = $data['MagentoOnePieceName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                    $columnI = $data['OnePiecePrice'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);

                    $columnK = '';

                    if (count($postColors) > 0) {
                        $columnK = 'size,color';
                    } else {
                        $columnK = 'size';
                    }

                    $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                    $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'Enabled');
                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, 'Yes');
                    $columnR = $data['DescriptionOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, $columnR);
                    $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '1');
                    $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '1');
                    $objPHPExcel->getActiveSheet()->SetCellValue('V' . $row, '1');
                    $objPHPExcel->getActiveSheet()->SetCellValue('W' . $row, $columnH);
                    $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $columnD);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $associated);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, 'Catalog, Search');
                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, 'Taxable Goods');
                    $columnAJ = 'One Piece';
                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                } else {
                    $associated = '';
                    foreach ($postSizes as $keySizes => $valueSizes) {
                        $row++;
                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, 'admin');
                        $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, 'base');
                        $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'SizeStyleColour');
                        $columnD = 'simple';
                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                        $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, '');
                        $columnF = $data['BaseSKUName'] . '-SZ' . $keySizes;
                        $associated .= $columnF . ',';
                        $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                        $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, '0');
                        $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnF);
                        $columnI = $data['OnePiecePrice'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);
                        $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, '');
                        $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'Enabled');
                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, 'Yes');
                        $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, $valueSizes);
                        $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, '');
                        $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, '2');
                        $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('V' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('W' . $row, $columnF);
                        $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $columnD);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, 'Not Visible Individually');
                        $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, 'Taxable Goods');
                        $columnAJ = 'One Piece';
                        $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                    }
                    $row++;
                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, 'admin');
                    $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, 'base');
                    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'SizeStyleColour');
                    $columnD = 'configurable';
                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                    $columnE = $data['MagentoOnePieceCategory'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, $columnE);
                    $columnF = $data['BaseSKUName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, '1');
                    $columnH = $data['MagentoOnePieceName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('H' . $row, $columnH);
                    $columnI = $data['OnePiecePrice'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('I' . $row, $columnI);

                    $columnK = '';

                    if (count($postColors) > 0) {
                        $columnK = 'size,color';
                    } else {
                        $columnK = 'size';
                    }

                    $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);

                    $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, 'Enabled');
                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, 'Yes');
                    $columnR = $data['DescriptionOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, $columnR);
                    $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '1');
                    $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '1');
                    $objPHPExcel->getActiveSheet()->SetCellValue('V' . $row, '1');
                    $objPHPExcel->getActiveSheet()->SetCellValue('W' . $row, $columnH);
                    $objPHPExcel->getActiveSheet()->SetCellValue('X' . $row, $columnD);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $associated);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, 'Catalog, Search');
                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, 'Taxable Goods');
                    $columnAJ = 'One Piece';
                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                }
                break;
        }

        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename="' . $file_name . '"');
        header('Cache-Control: max-age=0');
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        $objWriter->save('php://output');
        break;

    //AMAZON USA
    case 'generate-amazon-usa':
        $sheetDataEAN = $ean_used_codes = $ean_free_codes = array();
        if (file_exists($ean_file_name)) {
            $objPHPExcelEAN = PHPExcel_IOFactory::load($ean_file_name);
            $objPHPExcelEAN->setActiveSheetIndex(0);
            $sheetDataEAN = $objPHPExcelEAN->getActiveSheet()->toArray(null, true, true, true);
            $i = 0;
            foreach ($sheetDataEAN as $ean_code) {
                $i++;
                if ($i > 1 && $ean_code['A']) {
                    if (trim($ean_code['B'])) {
                        $ean_used_codes[strtoupper(trim($ean_code['B']))] = $ean_code['A'];
                    } else {
                        $ean_free_codes[$i] = $ean_code['A'];
                    }
                }
            }
        }
        $row = 3;
        $file_name = $data['BaseSKUName'] . '-AMAZON-USA.xlsx';

        switch ($data['IsSetType']) {
            case 'IsBikiniSet':
                if (count($postColors) > 0) {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        if ($valueEntries != 'SET') {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-' . $valueEntries;
                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $columnB = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries));
                            $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $columnF = $data['Description' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                            $columnG = $data['AMZItemType' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AO' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AP' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AQ' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AR' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BQ' . $row, 'parent');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, 'SizeColor');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CO' . $row, 'womens');
                            foreach ($postColors as $keyColors => $valueColors) {
                                foreach ($postSizes as $keySizes => $valueSizes) {
                                    $row++;
                                    if ($data['StyleBeforeColor']) {
                                        $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-' . $keyColors . '-SZ' . $keySizes;
                                    } else {
                                        $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-SZ' . $keySizes;
                                    }
                                    $columnAZ = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-Front.jpg';
                                    $columnBA = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-Back.jpg';
                                    $columnB = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries)) . ' ' . $valueColors . ' ' . $valueSizes;
                                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);

                                    if (isset($ean_used_codes[strtoupper($columnA)])) {
                                        $ean = $ean_used_codes[strtoupper($columnA)];
                                        $objPHPExcel->getActiveSheet()->getCell('C' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                    } elseif (isset($objPHPExcelEAN)) {
                                        foreach ($ean_free_codes as $ean_row => $code_value) {
                                            $ean = $code_value;
                                            $objPHPExcel->getActiveSheet()->getCell('C' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                            unset($ean_free_codes[$ean_row]);
                                            if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                                $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                                $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                                $objWriter->save($ean_file_name);
                                            }
                                            break;
                                        }
                                    }

                                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, 'EAN');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                                    $columnF = $data['Description' . $valueEntries];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                                    $columnG = $data['AMZItemType' . $valueEntries];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                    $columnJ = $data[$valueEntries . 'PRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnJ);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'USD');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, '1');
                                    $columnS = $data[$valueEntries . 'SALEPRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, $columnS);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '2014-07-01');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '2018-07-01');
                                    $columnAC = $data['AMZItemWeight'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, 'GR');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, 'GR');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $columnAC);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, 'CM');
                                    $columnAH = $data['AMZItemLength'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $columnAH);
                                    $columnAI = $data['AMZItemWidth'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $columnAI);
                                    $columnAJ = $data['AMZItemHeight'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint1']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint2']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint3']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint4']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AO' . $row, $data['AMZBullerPoint5']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AP' . $row, $data['AMZKeyword1']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AQ' . $row, $data['AMZKeyword2']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AR' . $row, $data['AMZKeyword3']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $data['AMZKeyword4']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $data['AMZKeyword5']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AZ' . $row, $columnAZ);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BA' . $row, $columnBA);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['AMZItemHeight']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, $data['AMZItemWidth']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, $data['AMZItemLength']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'CM');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BO' . $row, $data['AMZItemWeight']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BQ' . $row, 'child');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BR' . $row, $data['BaseSKUName'] . '-' . $valueEntries);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BS' . $row, 'Variation');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, 'SizeColor');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('CJ' . $row, $valueColors);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('CK' . $row, $valueColors);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('CO' . $row, 'womens');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('DP' . $row, $valueSizes);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('DQ' . $row, $valueSizes);
                                }
                            }
                        }
                    }
                } else {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        if ($valueEntries != 'SET') {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-' . $valueEntries;
                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $columnB = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries));
                            $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $columnF = $data['Description' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                            $columnG = $data['AMZItemType' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AO' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AP' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AQ' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AR' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BQ' . $row, 'parent');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, 'Size');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CO' . $row, 'womens');
                            foreach ($postSizes as $keySizes => $valueSizes) {
                                $row++;
                                $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-SZ' . $keySizes;
                                $columnB = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries)) . ' ' . $valueSizes;

                                $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);

                                if (isset($ean_used_codes[strtoupper($columnA)])) {
                                    $ean = $ean_used_codes[strtoupper($columnA)];
                                    $objPHPExcel->getActiveSheet()->getCell('C' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                } elseif (isset($objPHPExcelEAN)) {
                                    foreach ($ean_free_codes as $ean_row => $code_value) {
                                        $ean = $code_value;
                                        $objPHPExcel->getActiveSheet()->getCell('C' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                        unset($ean_free_codes[$ean_row]);
                                        if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                            $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                            $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                            $objWriter->save($ean_file_name);
                                        }
                                        break;
                                    }
                                }

                                $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, 'EAN');
                                $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                                $columnF = $data['Description' . $valueEntries];
                                $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                                $columnG = $data['AMZItemType' . $valueEntries];
                                $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                $columnJ = $data[$valueEntries . 'PRICE'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);
                                $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnJ);
                                $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'USD');
                                $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                                $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, '1');
                                $columnS = $data[$valueEntries . 'SALEPRICE'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, $columnS);
                                $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '2014-07-01');
                                $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '2018-07-01');
                                $columnAC = $data['AMZItemWeight'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, 'GR');
                                $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, 'GR');
                                $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $columnAC);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, 'CM');
                                $columnAH = $data['AMZItemLength'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $columnAH);
                                $columnAI = $data['AMZItemWidth'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $columnAI);
                                $columnAJ = $data['AMZItemHeight'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint1']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint2']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint3']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint4']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AO' . $row, $data['AMZBullerPoint5']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AP' . $row, $data['AMZKeyword1']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AQ' . $row, $data['AMZKeyword2']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AR' . $row, $data['AMZKeyword3']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $data['AMZKeyword4']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $data['AMZKeyword5']);

                                $columnAZ = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '-Front.jpg';
                                $objPHPExcel->getActiveSheet()->SetCellValue('AZ' . $row, $columnAZ);
                                $columnBA = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '-Back.jpg';
                                $objPHPExcel->getActiveSheet()->SetCellValue('BA' . $row, $columnBA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['AMZItemHeight']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, $data['AMZItemWidth']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, $data['AMZItemLength']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'CM');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BO' . $row, $data['AMZItemWeight']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BQ' . $row, 'child');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BR' . $row, $data['BaseSKUName'] . '-' . $valueEntries);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BS' . $row, 'Variation');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, 'Size');
                                $objPHPExcel->getActiveSheet()->SetCellValue('CO' . $row, 'womens');
                                $objPHPExcel->getActiveSheet()->SetCellValue('DP' . $row, $valueSizes);
                                $objPHPExcel->getActiveSheet()->SetCellValue('DQ' . $row, $valueSizes);
                            }
                        }
                    }
                }
                break;

            case 'IsOnePiece':
                if (count($postColors) > 0) {
                    $row++;
                    $columnA = $data['BaseSKUName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                    $columnB = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top';
                    $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                    $columnF = $data['DescriptionOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                    $columnG = $data['AMZItemTypeOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AO' . $row, $data['AMZBullerPoint5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AP' . $row, $data['AMZKeyword1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AQ' . $row, $data['AMZKeyword2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AR' . $row, $data['AMZKeyword3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $data['AMZKeyword4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $data['AMZKeyword5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('BQ' . $row, 'parent');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, 'SizeColor');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CO' . $row, 'womens');
                    foreach ($postColors as $keyColors => $valueColors) {
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-SZ' . $keySizes;
                            $columnB = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top ' . $valueColors . ' ' . $valueSizes;
                            $columnAZ = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-Front.jpg';
                            $columnBA = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-Back.jpg';

                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);

                            if (isset($ean_used_codes[strtoupper($columnA)])) {
                                $ean = $ean_used_codes[strtoupper($columnA)];
                                $objPHPExcel->getActiveSheet()->getCell('C' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                            } elseif (isset($objPHPExcelEAN)) {
                                foreach ($ean_free_codes as $ean_row => $code_value) {
                                    $ean = $code_value;
                                    $objPHPExcel->getActiveSheet()->getCell('C' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                    unset($ean_free_codes[$ean_row]);
                                    if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                        $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                        $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                        $objWriter->save($ean_file_name);
                                    }
                                    break;
                                }
                            }

                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, 'EAN');
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $columnF = $data['DescriptionOnePiece'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                            $columnG = $data['AMZItemTypeOnePiece'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $columnJ = $data['OnePiecePrice'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);
                            $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnJ);
                            $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'USD');
                            $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                            $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, '1');
                            $columnS = $data['OnePieceSalePrice'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, $columnS);
                            $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '2014-07-01');
                            $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '2018-07-01');
                            $columnAC = $data['AMZItemWeight'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, 'GR');
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, 'GR');
                            $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $columnAC);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, 'CM');
                            $columnAH = $data['AMZItemLength'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $columnAH);
                            $columnAI = $data['AMZItemWidth'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $columnAI);
                            $columnAJ = $data['AMZItemHeight'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AO' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AP' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AQ' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AR' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AZ' . $row, $columnAZ);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BA' . $row, $columnBA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['AMZItemHeight']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, $data['AMZItemWidth']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, $data['AMZItemLength']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'CM');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BO' . $row, $data['AMZItemWeight']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BQ' . $row, 'child');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BR' . $row, $data['BaseSKUName']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BS' . $row, 'Variation');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, 'SizeColor');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CJ' . $row, $valueColors);
                            $objPHPExcel->getActiveSheet()->SetCellValue('CK' . $row, $valueColors);
                            $objPHPExcel->getActiveSheet()->SetCellValue('CO' . $row, 'womens');
                            $objPHPExcel->getActiveSheet()->SetCellValue('DP' . $row, $valueSizes);
                            $objPHPExcel->getActiveSheet()->SetCellValue('DQ' . $row, $valueSizes);
                        }
                    }
                } else {
                    $row++;
                    $columnA = $data['BaseSKUName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                    $columnB = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top';
                    $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);
                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                    $columnF = $data['DescriptionOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                    $columnG = $data['AMZItemTypeOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AO' . $row, $data['AMZBullerPoint5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AP' . $row, $data['AMZKeyword1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AQ' . $row, $data['AMZKeyword2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AR' . $row, $data['AMZKeyword3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $data['AMZKeyword4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $data['AMZKeyword5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('BQ' . $row, 'parent');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, 'Size');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CO' . $row, 'womens');

                    foreach ($postSizes as $keySizes => $valueSizes) {
                        $row++;

                        $columnA = $data['BaseSKUName'] . '-SZ' . $keySizes;
                        $columnB = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top ' . $valueSizes;

                        $columnAZ = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-Front.jpg';
                        $columnBA = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-Back.jpg';

                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                        $objPHPExcel->getActiveSheet()->SetCellValue('B' . $row, $columnB);

                        if (isset($ean_used_codes[strtoupper($columnA)])) {
                            $ean = $ean_used_codes[strtoupper($columnA)];
                            $objPHPExcel->getActiveSheet()->getCell('C' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                        } elseif (isset($objPHPExcelEAN)) {
                            foreach ($ean_free_codes as $ean_row => $code_value) {
                                $ean = $code_value;
                                $objPHPExcel->getActiveSheet()->getCell('C' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                unset($ean_free_codes[$ean_row]);
                                if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                    $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                    $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                    $objWriter->save($ean_file_name);
                                }
                                break;
                            }
                        }

                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, 'EAN');
                        $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                        $columnF = $data['DescriptionOnePiece'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, $columnF);
                        $columnG = $data['AMZItemTypeOnePiece'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                        $columnJ = $data['OnePiecePrice'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('J' . $row, $columnJ);
                        $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnJ);
                        $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'USD');
                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                        $objPHPExcel->getActiveSheet()->SetCellValue('R' . $row, '1');
                        $columnS = $data['OnePieceSalePrice'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('S' . $row, $columnS);
                        $objPHPExcel->getActiveSheet()->SetCellValue('T' . $row, '2014-07-01');
                        $objPHPExcel->getActiveSheet()->SetCellValue('U' . $row, '2018-07-01');
                        $columnAC = $data['AMZItemWeight'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, 'GR');
                        $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, 'GR');
                        $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $columnAC);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, 'CM');
                        $columnAH = $data['AMZItemLength'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $columnAH);
                        $columnAI = $data['AMZItemWidth'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $columnAI);
                        $columnAJ = $data['AMZItemHeight'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $columnAJ);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint1']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint2']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint3']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint4']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AO' . $row, $data['AMZBullerPoint5']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AP' . $row, $data['AMZKeyword1']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AQ' . $row, $data['AMZKeyword2']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AR' . $row, $data['AMZKeyword3']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $data['AMZKeyword4']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $data['AMZKeyword5']);

                        $objPHPExcel->getActiveSheet()->SetCellValue('AZ' . $row, $columnAZ);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BA' . $row, $columnBA);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['AMZItemHeight']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, $data['AMZItemWidth']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, $data['AMZItemLength']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'CM');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BO' . $row, $data['AMZItemWeight']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BQ' . $row, 'child');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BR' . $row, $data['BaseSKUName']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BS' . $row, 'Variation');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, 'Size');
                        $objPHPExcel->getActiveSheet()->SetCellValue('CO' . $row, 'womens');
                        $objPHPExcel->getActiveSheet()->SetCellValue('DP' . $row, $valueSizes);
                        $objPHPExcel->getActiveSheet()->SetCellValue('DQ' . $row, $valueSizes);
                    }
                }
                break;
        }

        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename="' . $file_name . '"');
        header('Cache-Control: max-age=0');
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        $objWriter->save('php://output');
        break;

    //AMAZON UK
    case 'generate-amazon-uk':
        $sheetDataEAN = $ean_used_codes = $ean_free_codes = array();
        if (file_exists($ean_file_name)) {
            $objPHPExcelEAN = PHPExcel_IOFactory::load($ean_file_name);
            $objPHPExcelEAN->setActiveSheetIndex(0);
            $sheetDataEAN = $objPHPExcelEAN->getActiveSheet()->toArray(null, true, true, true);
            $i = 0;
            foreach ($sheetDataEAN as $ean_code) {
                $i++;
                if ($i > 1 && $ean_code['A']) {
                    if (trim($ean_code['B'])) {
                        $ean_used_codes[strtoupper(trim($ean_code['B']))] = $ean_code['A'];
                    } else {
                        $ean_free_codes[$i] = $ean_code['A'];
                    }
                }
            }
        }
        $row = 3;
        $file_name = $data['BaseSKUName'] . '-AMAZON-UK.xlsx';

        switch ($data['IsSetType']) {
            case 'IsBikiniSet':
                if (count($postColors) > 0) {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        if ($valueEntries != 'SET') {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-' . $valueEntries;
                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries));
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                            $columnG = $data['Description' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $columnAC = $data['AMZItemType' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'parent');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'SizeColor');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetic');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CF' . $row, 'Hand wash only');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CH' . $row, 'Women');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CI' . $row, 'FALSE');
                            foreach ($postColors as $keyColors => $valueColors) {
                                foreach ($postSizes as $keySizes => $valueSizes) {
                                    $row++;
                                    if ($data['StyleBeforeColor']) {
                                        $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-' . $keyColors . '-SZ' . $keySizes;
                                    } else {
                                        $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-SZ' . $keySizes;
                                    }
                                    $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-Front.jpg';
                                    $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-Back.jpg';
                                    $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries)) . ' ' . $valueColors . ' ' . $valueSizes;

                                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);

                                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                    if (isset($ean_used_codes[strtoupper($columnA)])) {
                                        $ean = $ean_used_codes[strtoupper($columnA)];
                                        $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                    } elseif (isset($objPHPExcelEAN)) {
                                        foreach ($ean_free_codes as $ean_row => $code_value) {
                                            $ean = $code_value;
                                            $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                            unset($ean_free_codes[$ean_row]);
                                            if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                                $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                                $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                                $objWriter->save($ean_file_name);
                                            }
                                            break;
                                        }
                                    }

                                    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                                    $columnG = $data['Description' . $valueEntries];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                    $columnK = $data[$valueEntries . 'PRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'GBP');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                                    $columnO = $data[$valueEntries . 'SALEPRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                                    $columnAA = $data['AMZItemWeight'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AA' . $row, $columnAA);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, 'GR');
                                    $columnAC = $data['AMZItemType' . $valueEntries];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $columnAS);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAT);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BD' . $row, $data['AMZItemLength']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemWidth']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemHeight']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, 'CM');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, $data['AMZItemWeight']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, 'GR');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'child');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['BaseSKUName'] . '-' . $valueEntries);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, 'Variation');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'SizeColor');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BR' . $row, $valueColors);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BS' . $row, $valueColors);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, $valueSizes);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetic');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('CF' . $row, 'Hand wash only');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('CH' . $row, 'Women');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('CI' . $row, 'FALSE');
                                }
                            }
                        }
                    }
                } else {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        if ($valueEntries != 'SET') {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-' . $valueEntries;
                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries));
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                            $columnG = $data['Description' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $columnAC = $data['AMZItemType' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'parent');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Size');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetic');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CF' . $row, 'Hand wash only');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CH' . $row, 'Women');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CI' . $row, 'FALSE');
                            foreach ($postSizes as $keySizes => $valueSizes) {
                                $row++;
                                $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-SZ' . $keySizes;
                                $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries)) . ' ' . $valueSizes;

                                $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);

                                $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                if (isset($ean_used_codes[strtoupper($columnA)])) {
                                    $ean = $ean_used_codes[strtoupper($columnA)];
                                    $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                } elseif (isset($objPHPExcelEAN)) {
                                    foreach ($ean_free_codes as $ean_row => $code_value) {
                                        $ean = $code_value;
                                        $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                        unset($ean_free_codes[$ean_row]);
                                        if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                            $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                            $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                            $objWriter->save($ean_file_name);
                                        }
                                        break;
                                    }
                                }

                                $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                                $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                                $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                                $columnG = $data['Description' . $valueEntries];
                                $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                $columnK = $data[$valueEntries . 'PRICE'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                                $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'GBP');
                                $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                                $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                                $columnO = $data[$valueEntries . 'SALEPRICE'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                                $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                                $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                                $columnAA = $data['AMZItemWeight'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('AA' . $row, $columnAA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, 'GR');
                                $columnAC = $data['AMZItemType' . $valueEntries];
                                $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                                $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '-Front.jpg';
                                $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $columnAS);
                                $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '-Back.jpg';
                                $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAT);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BD' . $row, $data['AMZItemLength']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemWidth']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemHeight']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, 'CM');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, $data['AMZItemWeight']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, 'GR');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'child');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['BaseSKUName'] . '-' . $valueEntries);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, 'Variation');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Size');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, $valueSizes);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetic');
                                $objPHPExcel->getActiveSheet()->SetCellValue('CF' . $row, 'Hand wash only');
                                $objPHPExcel->getActiveSheet()->SetCellValue('CH' . $row, 'Women');
                                $objPHPExcel->getActiveSheet()->SetCellValue('CI' . $row, 'FALSE');
                            }
                        }
                    }
                }
                break;

            case 'IsOnePiece':
                if (count($postColors) > 0) {
                    $row++;
                    $columnA = $data['BaseSKUName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                    $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top';
                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                    $columnG = $data['DescriptionOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                    $columnAC = $data['AMZItemTypeOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'parent');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'SizeColor');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetic');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CF' . $row, 'Hand wash only');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CH' . $row, 'Women');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CI' . $row, 'FALSE');
                    foreach ($postColors as $keyColors => $valueColors) {
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-SZ' . $keySizes;
                            $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top ' . $valueColors . ' ' . $valueSizes;
                            $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-Front.jpg';
                            $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-Back.jpg';

                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                            if (isset($ean_used_codes[strtoupper($columnA)])) {
                                $ean = $ean_used_codes[strtoupper($columnA)];
                                $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                            } elseif (isset($objPHPExcelEAN)) {
                                foreach ($ean_free_codes as $ean_row => $code_value) {
                                    $ean = $code_value;
                                    $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                    unset($ean_free_codes[$ean_row]);
                                    if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                        $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                        $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                        $objWriter->save($ean_file_name);
                                    }
                                    break;
                                }
                            }

                            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                            $columnG = $data['DescriptionOnePiece'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $columnK = $data['OnePiecePrice'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                            $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'GBP');
                            $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                            $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                            $columnO = $data['OnePieceSalePrice'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                            $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                            $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                            $columnAA = $data['AMZItemWeight'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AA' . $row, $columnAA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, 'GR');
                            $columnAC = $data['AMZItemTypeOnePiece'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $columnAS);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAT);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BD' . $row, $data['AMZItemLength']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemWidth']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemHeight']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, 'CM');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, $data['AMZItemWeight']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, 'GR');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'child');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['BaseSKUName']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, 'Variation');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'SizeColor');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BR' . $row, $valueColors);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BS' . $row, $valueColors);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, $valueSizes);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetic');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CF' . $row, 'Hand wash only');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CH' . $row, 'Women');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CI' . $row, 'FALSE');
                        }
                    }
                } else {
                    $row++;
                    $columnA = $data['BaseSKUName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                    $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top';
                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                    $columnG = $data['DescriptionOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                    $columnAC = $data['AMZItemTypeOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'parent');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Size');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetic');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CF' . $row, 'Hand wash only');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CH' . $row, 'Women');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CI' . $row, 'FALSE');

                    foreach ($postSizes as $keySizes => $valueSizes) {
                        $row++;
                        $columnA = $data['BaseSKUName'] . '-SZ' . $keySizes;
                        $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top ' . $valueSizes;

                        $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-Front.jpg';
                        $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-Back.jpg';

                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                        if (isset($ean_used_codes[strtoupper($columnA)])) {
                            $ean = $ean_used_codes[strtoupper($columnA)];
                            $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                        } elseif (isset($objPHPExcelEAN)) {
                            foreach ($ean_free_codes as $ean_row => $code_value) {
                                $ean = $code_value;
                                $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                unset($ean_free_codes[$ean_row]);
                                if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                    $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                    $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                    $objWriter->save($ean_file_name);
                                }
                                break;
                            }
                        }

                        $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                        $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                        $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                        $columnG = $data['DescriptionOnePiece'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                        $columnK = $data['OnePiecePrice'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                        $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'GBP');
                        $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                        $columnO = $data['OnePieceSalePrice'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                        $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                        $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                        $columnAA = $data['AMZItemWeight'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('AA' . $row, $columnAA);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, 'GR');
                        $columnAC = $data['AMZItemTypeOnePiece'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $columnAS);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAT);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BD' . $row, $data['AMZItemLength']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemWidth']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemHeight']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, 'CM');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, $data['AMZItemWeight']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, 'GR');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'child');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['BaseSKUName']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, 'Variation');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Size');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, $valueSizes);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetic');
                        $objPHPExcel->getActiveSheet()->SetCellValue('CF' . $row, 'Hand wash only');
                        $objPHPExcel->getActiveSheet()->SetCellValue('CH' . $row, 'Women');
                        $objPHPExcel->getActiveSheet()->SetCellValue('CI' . $row, 'FALSE');
                    }
                }
                break;
        }

        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename="' . $file_name . '"');
        header('Cache-Control: max-age=0');
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        $objWriter->save('php://output');
        break;

    //AMAZON DE    
    case 'generate-amazon-de':
        $sheetDataEAN = $ean_used_codes = $ean_free_codes = array();
        if (file_exists($ean_file_name)) {
            $objPHPExcelEAN = PHPExcel_IOFactory::load($ean_file_name);
            $objPHPExcelEAN->setActiveSheetIndex(0);
            $sheetDataEAN = $objPHPExcelEAN->getActiveSheet()->toArray(null, true, true, true);
            $i = 0;
            foreach ($sheetDataEAN as $ean_code) {
                $i++;
                if ($i > 1 && $ean_code['A']) {
                    if (trim($ean_code['B'])) {
                        $ean_used_codes[strtoupper(trim($ean_code['B']))] = $ean_code['A'];
                    } else {
                        $ean_free_codes[$i] = $ean_code['A'];
                    }
                }
            }
        }
        $row = 3;
        $file_name = $data['BaseSKUName'] . '-AMAZON-DE.xlsx';

        switch ($data['IsSetType']) {
            case 'IsBikiniSet':
                if (count($postColors) > 0) {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        if ($valueEntries != 'SET') {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-' . $valueEntries;
                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries));
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                            $columnG = $data['Description' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $columnAC = $data['AMZItemType' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $columnAC);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, 'parent');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'SizeColor');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetisch');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'Damen');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CE' . $row, 'FALSE');
                            foreach ($postColors as $keyColors => $valueColors) {
                                foreach ($postSizes as $keySizes => $valueSizes) {
                                    $row++;
                                    if ($data['StyleBeforeColor']) {
                                        $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-' . $keyColors . '-SZ' . $keySizes;
                                        $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . $valueColors . ' ' . ucfirst(strtolower($valueEntries)) . ' ' . $valueSizes;
                                    } else {
                                        $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-SZ' . $keySizes;
                                        $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries)) . ' ' . $valueColors . ' ' . $valueSizes;
                                    }
                                    $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-Front.jpg';
                                    $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-Back.jpg';

                                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);

                                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                    if (isset($ean_used_codes[strtoupper($columnA)])) {
                                        $ean = $ean_used_codes[strtoupper($columnA)];
                                        $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                    } elseif (isset($objPHPExcelEAN)) {
                                        foreach ($ean_free_codes as $ean_row => $code_value) {
                                            $ean = $code_value;
                                            $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                            unset($ean_free_codes[$ean_row]);
                                            if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                                $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                                $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                                $objWriter->save($ean_file_name);
                                            }
                                            break;
                                        }
                                    }

                                    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                                    $columnG = $data['Description' . $valueEntries];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                    $columnK = $data[$valueEntries . 'PRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'EUR');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                                    $columnO = $data[$valueEntries . 'SALEPRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                                    $columnAA = $data['AMZItemWeight'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, $columnAA);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, 'GR');
                                    $columnAC = $data['AMZItemType' . $valueEntries];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $columnAC);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword1']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword2']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword3']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword4']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZKeyword5']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint1']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint2']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint3']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint4']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint5']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAS);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AU' . $row, $columnAT);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemLength']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemWidth']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, $data['AMZItemHeight']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, 'CM');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, $data['AMZItemWeight']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'GR');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, 'child');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, $data['BaseSKUName'] . '-' . $valueEntries);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Variation');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'SizeColor');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BS' . $row, $valueColors);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, $valueColors);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, $valueSizes);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetisch');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'Damen');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('CE' . $row, 'FALSE');
                                }
                            }
                        }
                    }
                } else {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        if ($valueEntries != 'SET') {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-' . $valueEntries;
                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries));
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                            $columnG = $data['Description' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $columnAC = $data['AMZItemType' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $columnAC);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, 'parent');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'Size');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetisch');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'Damen');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CE' . $row, 'FALSE');
                            foreach ($postSizes as $keySizes => $valueSizes) {
                                $row++;
                                $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-SZ' . $keySizes;
                                $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries)) . ' ' . $valueSizes;

                                $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);

                                $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                if (isset($ean_used_codes[strtoupper($columnA)])) {
                                    $ean = $ean_used_codes[strtoupper($columnA)];
                                    $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                } elseif (isset($objPHPExcelEAN)) {
                                    foreach ($ean_free_codes as $ean_row => $code_value) {
                                        $ean = $code_value;
                                        $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                        unset($ean_free_codes[$ean_row]);
                                        if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                            $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                            $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                            $objWriter->save($ean_file_name);
                                        }
                                        break;
                                    }
                                }

                                $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                                $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                                $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                                $columnG = $data['Description' . $valueEntries];
                                $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                $columnK = $data[$valueEntries . 'PRICE'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                                $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'EUR');
                                $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                                $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                                $columnO = $data[$valueEntries . 'SALEPRICE'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                                $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                                $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                                $columnAA = $data['AMZItemWeight'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, $columnAA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, 'GR');
                                $columnAC = $data['AMZItemType' . $valueEntries];
                                $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $columnAC);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword1']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword2']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword3']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword4']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZKeyword5']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint1']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint2']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint3']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint4']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint5']);
                                $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '-Front.jpg';
                                $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAS);
                                $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '-Back.jpg';
                                $objPHPExcel->getActiveSheet()->SetCellValue('AU' . $row, $columnAT);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemLength']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemWidth']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, $data['AMZItemHeight']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, 'CM');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, $data['AMZItemWeight']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'GR');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, 'child');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, $data['BaseSKUName'] . '-' . $valueEntries);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Variation');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'Size');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, $valueSizes);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetisch');
                                $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'Damen');
                                $objPHPExcel->getActiveSheet()->SetCellValue('CE' . $row, 'FALSE');
                            }
                        }
                    }
                }
                break;

            case 'IsOnePiece':
                if (count($postColors) > 0) {
                    $row++;
                    $columnA = $data['BaseSKUName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                    $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top';
                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                    $columnG = $data['DescriptionOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                    $columnAD = $data['AMZItemTypeOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $columnAD);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZKeyword5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, 'parent');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'SizeColor');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetisch');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'Damen');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CE' . $row, 'FALSE');

                    foreach ($postColors as $keyColors => $valueColors) {
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            $row++;

                            $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-SZ' . $keySizes;
                            $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top ' . $valueColors . ' ' . $valueSizes;

                            $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-Front.jpg';
                            $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-Back.jpg';

                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                            if (isset($ean_used_codes[strtoupper($columnA)])) {
                                $ean = $ean_used_codes[strtoupper($columnA)];
                                $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                            } elseif (isset($objPHPExcelEAN)) {
                                foreach ($ean_free_codes as $ean_row => $code_value) {
                                    $ean = $code_value;
                                    $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                    unset($ean_free_codes[$ean_row]);
                                    if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                        $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                        $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                        $objWriter->save($ean_file_name);
                                    }
                                    break;
                                }
                            }

                            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                            $columnG = $data['DescriptionOnePiece'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $columnK = $data['OnePiecePrice'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                            $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'EUR');
                            $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                            $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                            $columnO = $data['OnePieceSalePrice'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                            $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                            $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                            $columnAA = $data['AMZItemWeight'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, $columnAA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, 'GR');
                            $columnAC = $data['AMZItemTypeOnePiece'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $columnAC);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAS);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AU' . $row, $columnAT);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemLength']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemWidth']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, $data['AMZItemHeight']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, 'CM');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, $data['AMZItemWeight']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'GR');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, 'child');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, $data['BaseSKUName']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Variation');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'SizeColor');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BS' . $row, $valueColors);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, $valueColors);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, $valueSizes);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetisch');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'Damen');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CE' . $row, 'FALSE');
                        }
                    }
                } else {

                    $row++;
                    $columnA = $data['BaseSKUName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                    $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top';
                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                    $columnG = $data['DescriptionOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                    $columnAD = $data['AMZItemTypeOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $columnAD);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZKeyword5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, 'parent');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'Size');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetisch');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'Damen');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CE' . $row, 'FALSE');

                    foreach ($postSizes as $keySizes => $valueSizes) {
                        $row++;

                        $columnA = $data['BaseSKUName'] . '-SZ' . $keySizes;
                        $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top ' . $valueSizes;

                        $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-Front.jpg';
                        $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-Back.jpg';

                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                        if (isset($ean_used_codes[strtoupper($columnA)])) {
                            $ean = $ean_used_codes[strtoupper($columnA)];
                            $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                        } elseif (isset($objPHPExcelEAN)) {
                            foreach ($ean_free_codes as $ean_row => $code_value) {
                                $ean = $code_value;
                                $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                unset($ean_free_codes[$ean_row]);
                                if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                    $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                    $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                    $objWriter->save($ean_file_name);
                                }
                                break;
                            }
                        }

                        $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                        $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                        $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                        $columnG = $data['DescriptionOnePiece'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                        $columnK = $data['OnePiecePrice'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                        $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'EUR');
                        $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                        $columnO = $data['OnePieceSalePrice'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                        $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                        $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                        $columnAA = $data['AMZItemWeight'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, $columnAA);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, 'GR');
                        $columnAC = $data['AMZItemTypeOnePiece'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $columnAC);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword1']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword2']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword3']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword4']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZKeyword5']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint1']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint2']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint3']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint4']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AN' . $row, $data['AMZBullerPoint5']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAS);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AU' . $row, $columnAT);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemLength']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemWidth']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, $data['AMZItemHeight']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, 'CM');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, $data['AMZItemWeight']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'GR');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, 'child');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, $data['BaseSKUName']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Variation');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BN' . $row, 'Size');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, $valueSizes);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, '82% Polyamid, 18% Elasten');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BX' . $row, 'Synthetisch');
                        $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'Damen');
                        $objPHPExcel->getActiveSheet()->SetCellValue('CE' . $row, 'FALSE');
                    }
                }
                break;
        }

        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename="' . $file_name . '"');
        header('Cache-Control: max-age=0');
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        $objWriter->save('php://output');
        break;

    //AMAZON FR
    case 'generate-amazon-fr':
        $sheetDataEAN = $ean_used_codes = $ean_free_codes = array();
        if (file_exists($ean_file_name)) {
            $objPHPExcelEAN = PHPExcel_IOFactory::load($ean_file_name);
            $objPHPExcelEAN->setActiveSheetIndex(0);
            $sheetDataEAN = $objPHPExcelEAN->getActiveSheet()->toArray(null, true, true, true);
            $i = 0;
            foreach ($sheetDataEAN as $ean_code) {
                $i++;
                if ($i > 1 && $ean_code['A']) {
                    if (trim($ean_code['B'])) {
                        $ean_used_codes[strtoupper(trim($ean_code['B']))] = $ean_code['A'];
                    } else {
                        $ean_free_codes[$i] = $ean_code['A'];
                    }
                }
            }
        }
        $row = 3;
        $file_name = $data['BaseSKUName'] . '-AMAZON-FR.xlsx';

        switch ($data['IsSetType']) {
            case 'IsBikiniSet':
                if (count($postColors) > 0) {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        if ($valueEntries != 'SET') {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-' . $valueEntries;
                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries));
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                            $columnG = $data['Description' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $columnAC = $data['AMZItemType' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'parent');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'SizeColor');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, '82% Polyamid, 18% Elasten');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, 'Synthétique');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CC' . $row, 'Femme');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'FALSE');
                            foreach ($postColors as $keyColors => $valueColors) {
                                foreach ($postSizes as $keySizes => $valueSizes) {
                                    $row++;
                                    if ($data['StyleBeforeColor']) {
                                        $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-' . $keyColors . '-SZ' . $keySizes;
                                        $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . $valueColors . ' ' . ucfirst(strtolower($valueEntries)) . ' ' . $valueSizes;
                                    } else {
                                        $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-SZ' . $keySizes;
                                        $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries)) . ' ' . $valueColors . ' ' . $valueSizes;
                                    }
                                    $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-Front.jpg';
                                    $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-' . $keyEntries . '-Back.jpg';

                                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                    if (isset($ean_used_codes[strtoupper($columnA)])) {
                                        $ean = $ean_used_codes[strtoupper($columnA)];
                                        $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                    } elseif (isset($objPHPExcelEAN)) {
                                        foreach ($ean_free_codes as $ean_row => $code_value) {
                                            $ean = $code_value;
                                            $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                            unset($ean_free_codes[$ean_row]);
                                            if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                                $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                                $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                                $objWriter->save($ean_file_name);
                                            }
                                            break;
                                        }
                                    }

                                    $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                                    $columnG = $data['Description' . $valueEntries];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                    $columnK = $data[$valueEntries . 'PRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'EUR');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                                    $columnO = $data[$valueEntries . 'SALEPRICE'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                                    $columnAA = $data['AMZItemWeight'];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AA' . $row, $columnAA);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, 'GR');
                                    $columnAC = $data['AMZItemType' . $valueEntries];
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $columnAS);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAT);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BD' . $row, $data['AMZItemLength']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemWidth']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemHeight']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, 'CM');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, $data['AMZItemWeight']);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, 'GR');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'child');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['BaseSKUName'] . '-' . $valueEntries);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, 'Variation');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'SizeColor');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BR' . $row, $valueColors);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BS' . $row, $valueColors);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, $valueSizes);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, '82% Polyamid, 18% Elasten');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, 'Synthétique');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('CC' . $row, 'Femme');
                                    $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'FALSE');
                                }
                            }
                        }
                    }
                } else {
                    foreach ($caseEntries as $keyEntries => $valueEntries) {
                        if ($valueEntries != 'SET') {
                            $row++;
                            $columnA = $data['BaseSKUName'] . '-' . $valueEntries;
                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries));
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                            $columnG = $data['Description' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $columnAC = $data['AMZItemType' . $valueEntries];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'parent');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Size');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, '82% Polyamid, 18% Elasten');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, 'Synthétique');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CC' . $row, 'Femme');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'FALSE');
                            foreach ($postSizes as $keySizes => $valueSizes) {
                                $row++;
                                $columnA = $data['BaseSKUName'] . '-' . $keyEntries . '-SZ' . $keySizes;
                                $columnD = $data['AMZPrefixForName'] . ' ' . $data['Magento' . $valueEntries . 'Name'] . ' Bikini ' . ucfirst(strtolower($valueEntries)) . ' ' . $valueSizes;

                                $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                                if (isset($ean_used_codes[strtoupper($columnA)])) {
                                    $ean = $ean_used_codes[strtoupper($columnA)];
                                    $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                } elseif (isset($objPHPExcelEAN)) {
                                    foreach ($ean_free_codes as $ean_row => $code_value) {
                                        $ean = $code_value;
                                        $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                        unset($ean_free_codes[$ean_row]);
                                        if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                            $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                            $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                            $objWriter->save($ean_file_name);
                                        }
                                        break;
                                    }
                                }

                                $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                                $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                                $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                                $columnG = $data['Description' . $valueEntries];
                                $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                                $columnK = $data[$valueEntries . 'PRICE'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                                $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'EUR');
                                $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                                $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                                $columnO = $data[$valueEntries . 'SALEPRICE'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                                $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                                $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                                $columnAA = $data['AMZItemWeight'];
                                $objPHPExcel->getActiveSheet()->SetCellValue('AA' . $row, $columnAA);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, 'GR');
                                $columnAC = $data['AMZItemType' . $valueEntries];
                                $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                                $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '-Front.jpg';
                                $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $columnAS);
                                $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyEntries . '-Back.jpg';
                                $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAT);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BD' . $row, $data['AMZItemLength']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemWidth']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemHeight']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, 'CM');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, $data['AMZItemWeight']);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, 'GR');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'child');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['BaseSKUName'] . '-' . $valueEntries);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, 'Variation');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Size');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, $valueSizes);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                                $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, '82% Polyamid, 18% Elasten');
                                $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, 'Synthétique');
                                $objPHPExcel->getActiveSheet()->SetCellValue('CC' . $row, 'Femme');
                                $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'FALSE');
                            }
                        }
                    }
                }
                break;

            case 'IsOnePiece':
                if (count($postColors) > 0) {
                    $row++;
                    $columnA = $data['BaseSKUName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                    $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top';
                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                    $columnG = $data['DescriptionOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                    $columnAC = $data['AMZItemTypeOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'parent');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'SizeColor');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, '82% Polyamid, 18% Elasten');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, 'Synthétique');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CC' . $row, 'Femme');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'FALSE');
                    foreach ($postColors as $keyColors => $valueColors) {
                        foreach ($postSizes as $keySizes => $valueSizes) {
                            $row++;

                            $columnA = $data['BaseSKUName'] . '-' . $keyColors . '-SZ' . $keySizes;
                            $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top ' . $valueColors . ' ' . $valueSizes;

                            $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-Front.jpg';
                            $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-' . $keyColors . '-Back.jpg';

                            $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                            if (isset($ean_used_codes[strtoupper($columnA)])) {
                                $ean = $ean_used_codes[strtoupper($columnA)];
                                $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                            } elseif (isset($objPHPExcelEAN)) {
                                foreach ($ean_free_codes as $ean_row => $code_value) {
                                    $ean = $code_value;
                                    $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                    unset($ean_free_codes[$ean_row]);
                                    if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                        $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                        $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                        $objWriter->save($ean_file_name);
                                    }
                                    break;
                                }
                            }

                            $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                            $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                            $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                            $columnG = $data['DescriptionOnePiece'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                            $columnK = $data['OnePiecePrice'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                            $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'EUR');
                            $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                            $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                            $columnO = $data['OnePieceSalePrice'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                            $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                            $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                            $columnAA = $data['AMZItemWeight'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AA' . $row, $columnAA);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, 'GR');
                            $columnAC = $data['AMZItemTypeOnePiece'];
                            $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $columnAS);
                            $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAT);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BD' . $row, $data['AMZItemLength']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemWidth']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemHeight']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, 'CM');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, $data['AMZItemWeight']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, 'GR');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'child');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['BaseSKUName']);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, 'Variation');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'SizeColor');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BR' . $row, $valueColors);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BS' . $row, $valueColors);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, $valueSizes);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                            $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, '82% Polyamid, 18% Elasten');
                            $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, 'Synthétique');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CC' . $row, 'Femme');
                            $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'FALSE');
                        }
                    }
                } else {
                    $row++;
                    $columnA = $data['BaseSKUName'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                    $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top';
                    $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);
                    $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                    $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                    $columnG = $data['DescriptionOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                    $columnAC = $data['AMZItemTypeOnePiece'];
                    $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                    $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'parent');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Size');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, '82% Polyamid, 18% Elasten');
                    $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, 'Synthétique');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CC' . $row, 'Femme');
                    $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'FALSE');

                    foreach ($postSizes as $keySizes => $valueSizes) {
                        $row++;

                        $columnA = $data['BaseSKUName'] . '-SZ' . $keySizes;
                        $columnD = $data['AMZPrefixForName'] . ' ' . $data['MagentoOnePieceName'] . ' Bikini Top ' . $valueSizes;

                        $columnAS = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-Front.jpg';
                        $columnAT = $data['ImageBase'] . '/' . $data['BaseSKUName'] . '-Back.jpg';

                        $objPHPExcel->getActiveSheet()->SetCellValue('A' . $row, $columnA);
                        $objPHPExcel->getActiveSheet()->SetCellValue('D' . $row, $columnD);

                        if (isset($ean_used_codes[strtoupper($columnA)])) {
                            $ean = $ean_used_codes[strtoupper($columnA)];
                            $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                        } elseif (isset($objPHPExcelEAN)) {
                            foreach ($ean_free_codes as $ean_row => $code_value) {
                                $ean = $code_value;
                                $objPHPExcel->getActiveSheet()->getCell('B' . $row)->setValueExplicit($ean, PHPExcel_Cell_DataType::TYPE_STRING);
                                unset($ean_free_codes[$ean_row]);
                                if (!isset($data['EANTestMode']) || !$data['EANTestMode']) {
                                    $objPHPExcelEAN->getActiveSheet()->SetCellValue('B' . $ean_row, strtoupper($columnA));
                                    $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcelEAN);
                                    $objWriter->save($ean_file_name);
                                }
                                break;
                            }
                        }

                        $objPHPExcel->getActiveSheet()->SetCellValue('C' . $row, 'EAN');
                        $objPHPExcel->getActiveSheet()->SetCellValue('E' . $row, 'Sheridyn Swim');
                        $objPHPExcel->getActiveSheet()->SetCellValue('F' . $row, 'Swimwear');
                        $columnG = $data['DescriptionOnePiece'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('G' . $row, $columnG);
                        $columnK = $data['OnePiecePrice'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('K' . $row, $columnK);
                        $objPHPExcel->getActiveSheet()->SetCellValue('L' . $row, 'EUR');
                        $objPHPExcel->getActiveSheet()->SetCellValue('M' . $row, '1');
                        $objPHPExcel->getActiveSheet()->SetCellValue('N' . $row, '6');
                        $columnO = $data['OnePieceSalePrice'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('O' . $row, $columnO);
                        $objPHPExcel->getActiveSheet()->SetCellValue('P' . $row, '2014-07-01');
                        $objPHPExcel->getActiveSheet()->SetCellValue('Q' . $row, '2018-07-01');
                        $columnAA = $data['AMZItemWeight'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('AA' . $row, $columnAA);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AB' . $row, 'GR');
                        $columnAC = $data['AMZItemTypeOnePiece'];
                        $objPHPExcel->getActiveSheet()->SetCellValue('AC' . $row, $columnAC);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AD' . $row, $data['AMZKeyword1']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AE' . $row, $data['AMZKeyword2']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AF' . $row, $data['AMZKeyword3']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AG' . $row, $data['AMZKeyword4']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AH' . $row, $data['AMZKeyword5']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AI' . $row, $data['AMZBullerPoint1']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AJ' . $row, $data['AMZBullerPoint2']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AK' . $row, $data['AMZBullerPoint3']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AL' . $row, $data['AMZBullerPoint4']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AM' . $row, $data['AMZBullerPoint5']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AS' . $row, $columnAS);
                        $objPHPExcel->getActiveSheet()->SetCellValue('AT' . $row, $columnAT);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BD' . $row, $data['AMZItemLength']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BE' . $row, $data['AMZItemWidth']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BF' . $row, $data['AMZItemHeight']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BG' . $row, 'CM');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BH' . $row, $data['AMZItemWeight']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BI' . $row, 'GR');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BJ' . $row, 'child');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BK' . $row, $data['BaseSKUName']);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BL' . $row, 'Variation');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BM' . $row, 'Size');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BT' . $row, $valueSizes);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BU' . $row, $valueSizes);
                        $objPHPExcel->getActiveSheet()->SetCellValue('BV' . $row, '82% Polyamid, 18% Elasten');
                        $objPHPExcel->getActiveSheet()->SetCellValue('BW' . $row, 'Synthétique');
                        $objPHPExcel->getActiveSheet()->SetCellValue('CC' . $row, 'Femme');
                        $objPHPExcel->getActiveSheet()->SetCellValue('CD' . $row, 'FALSE');
                    }
                }
                break;
        }

        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename="' . $file_name . '"');
        header('Cache-Control: max-age=0');
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        $objWriter->save('php://output');
        break;

    //Download file (don't use)
    case 'download-ean-file':
        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename="' . $ean_file_name . '"');
        header('Cache-Control: max-age=0');
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        $objWriter->save('php://output');
        break;
    default:
        break;
}



